package org.example.huweb.config;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class webInterceptorConfirm implements WebMvcConfigurer {

    private final HandlerInterceptor handlerInterceptor;

    /***
     * web 拦截器注册
     * @param registry 拦截器注册表
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        setInterceptor(registry);
    }

    //设置拦截器
    public void setInterceptor(InterceptorRegistry registry) {
        registry.addInterceptor(handlerInterceptor)
                .addPathPatterns("/api/**") // 拦截所有请求路径
                .excludePathPatterns("/api/longinTxt") // 排除登录接口
                .excludePathPatterns("/api/loginPost")
                .excludePathPatterns("/api/enrollUserPost")
                .excludePathPatterns("/api/carousel/list"); // 获取轮播图列表
//               .excludePathPatterns("/api/carousel/add"); // 获取轮播图列表
    }

    //设置静态资源访问

}

